﻿Namespace FTTK.Utilities
    ''' <summary>
    ''' Contains all Fotolia error message and allow to retrieve them by code
    ''' </summary>
    ''' <remarks></remarks>
    Friend NotInheritable Class FotoliaErrorMessages

        Private Sub New()

        End Sub

        Shared Sub New()
            _Messages = New Dictionary(Of String, String)
            _Messages.Add("1", "Service currently unavailable ")
            _Messages.Add("2", "Failed to parse request")
            _Messages.Add("10", " Missing API Key")
            _Messages.Add("11", "Invalid API Key")
            _Messages.Add("31", "Invalid Method")
            _Messages.Add("32", "Method not Available")
            _Messages.Add("100", "Missing Media ID")
            _Messages.Add("101", "Invalid Media ID")
            _Messages.Add("2001", "Invalid Language ID")
            _Messages.Add("2101", "Invalid Thumbnail Size")
            _Messages.Add("301", "Invalid Category ID")
            _Messages.Add("5001", "Invalid Tag Type")
            _Messages.Add("601", "Invalid Color ID")
            _Messages.Add("4000", "Login Failed")
            _Messages.Add("4001", "Invalid User")
            _Messages.Add("4002", "Bad Login or Password")
            _Messages.Add("020", "Missing Session Token")
            _Messages.Add("021", "Invalid Session Token")
            _Messages.Add("2401", "Invalid Gallery ID")
            _Messages.Add("2301", "Invalid Gallery Name")
            _Messages.Add("10000", "Unknown Gallery ID")
            _Messages.Add("2402", "Unknown media ID ")
        End Sub

        Private Shared _Messages As Dictionary(Of String, String)
        Private Shared _DefaultMessage As String = "Internal error"

        ''' <summary>
        ''' Gets the message by error code.
        ''' </summary>
        ''' <param name="errorCode">The error code.</param>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Shared Function GetMessageByErrorCode(errorCode As String) As String
            If _Messages.ContainsKey(errorCode) Then
                Return _Messages(errorCode)
            Else
                Return _DefaultMessage
            End If
        End Function

        ''' <summary>
        ''' Gets the default message.
        ''' </summary>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Shared Function GetDefaultMessage() As String
            Return _DefaultMessage
        End Function

    End Class
End Namespace
